/*******************************************************************************
Title:			Kenya GE Clean
Written by:		Katherine Dai
Purpose:		Clean COVID Mental Health Data for Kenya GE

Organization: 	1. Sleep  			
                2. Happiness
				3. Depression
				4. Stress
				5. Nervous
				6. Concentration
				7. Effort 
				8. Difficulties
				9. Loneliness
				10. Fear
				11. Hope
				12. Bothering
				13. Worthlessness
*******************************************************************************/

*-------------------------------------------------------------------------------
* Setup
*-------------------------------------------------------------------------------
*do "/Users/Katherine/Dropbox/COVID-mental health/99.Common/globals.do"
clear all 

gl in ${raw}/kenya_ge/raw
gl out ${raw}/kenya_ge

use "${in}/Kenya_GE_COVID-MentalHealth_seasonality.dta", clear 
drop if mi(hhid) | mi(round)
isid hhid round

*-------------------------------------------------------------------------------
* Data Subsetting 
*------------------------------------------------------------------------------

drop E_s1_q4a_resptype   //


*-------------------------------------------------------------------------------
* 1. Sleep
*-------------------------------------------------------------------------------
* Pre- and post-COVID data from rounds 1, 2, and 3 available

replace s6_q12 = s6_q12 + 1

ren E_s14_q7_cesd7 sleep
replace sleep = s6_q12 if inlist(round, 2,3) & mi(sleep)

replace sleep = .n if inlist(sleep, .,-88)
drop s6_q12

label define sleep_label			1 "Never + rarely" ///
							        2 "Sometimes" ///
							        3 "Often" ///
							        4 "Always" //
label values sleep sleep_label

*-------------------------------------------------------------------------------
* 2. Happiness
*-------------------------------------------------------------------------------
* Post-COVID data from rounds 2 and 3 available

replace s6_q13 = s6_q13 + 1

ren E_s14_q8_cesd8 happiness
replace happiness = s6_q13 if inlist(round, 2,3) & mi(happiness)

replace happiness = .n if inlist(happiness, .,-88)
drop s6_q13

label define happiness_label			1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values happiness happiness_label

*-------------------------------------------------------------------------------
* Pre-COVID data from round 1 available 

ren (E_s14_q23_wvs_happiness E_s14_q24_wvs_satisfaction) ///
	(happiness2 happiness3)
replace happiness2 = .n if inlist(happiness2, .,-88)
replace happiness3 = .n if inlist(happiness3, .,-88)


*-------------------------------------------------------------------------------
* 3. Depression
*-------------------------------------------------------------------------------
* Pre- and post-COVID data from rounds 1, 2, and 3 available

replace s6_q2 = s6_q2 + 1
replace s6_q8 = s6_q8 + 1

ren E_s14_q3_cesd3 depression
replace depression = s6_q2 if inlist(round, 2,3) & mi(depression)
replace depression = s6_q8 if inlist(round, 2,3) & mi(depression)

replace depression = .n if inlist(depression, .,-88)
drop s6_q2 s6_q8

label define depression_label			1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values depression depression_label

*-------------------------------------------------------------------------------
* 4. Stress
*-------------------------------------------------------------------------------
* Post-COVID data from rounds 2 and 3 available

replace s6_q5 = s6_q5 + 1
ren s6_q5 stress
replace stress = .n if inlist(stress, .,-88)
label define stress_label				1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values stress stress_label

*-------------------------------------------------------------------------------
* 5. Nervous
*-------------------------------------------------------------------------------
* Post-COVID data from rounds 2 and 3 available

replace s6_q1 = s6_q1 + 1
ren s6_q1 nervous
replace nervous = .n if inlist(nervous, .,-88)
label define nervous_label				1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values nervous nervous_label

*-------------------------------------------------------------------------------
* 6. Concentration
*-------------------------------------------------------------------------------
* Pre- and post-COVID data from rounds 1, 2, and 3 available

replace s6_q7 = s6_q7 + 1

ren E_s14_q2_cesd2 concentration 
replace concentration = s6_q7 if inlist(round, 2,3) & mi(concentration)

replace concentration = .n if inlist(concentration, .,-88)
drop s6_q7

label define concentration_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values concentration concentration_label

*-------------------------------------------------------------------------------
* 7. Effort
*-------------------------------------------------------------------------------
* Pre- and post-COVID data from rounds 1, 2, and 3 available

replace s6_q9 = s6_q9 + 1

ren E_s14_q4_cesd4 effort 
replace effort = s6_q9 if inlist(round, 2,3) & mi(effort)

replace effort = .n if inlist(effort, .,-88)
drop s6_q9

label define effort_label						1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values effort effort_label

*-------------------------------------------------------------------------------
* 8. Difficulties
*-------------------------------------------------------------------------------
* Pre- and post-COVID data from rounds 1, 2, and 3 available

replace s6_q15 = s6_q15 + 1

ren E_s14_q10_cesd10 difficulties1 
destring difficulties1, replace ignore ("")
replace difficulties1 = s6_q15 if inlist(round, 2,3) & mi(difficulties1)

replace difficulties1 = .n if inlist(difficulties1, .,-88)
drop s6_q15 

label define difficulties1_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values difficulties1 difficulties1_label

*-------------------------------------------------------------------------------
* Pre-COVID data from round 1 available 

ren (E_s15_5_q1_loc_15 E_s15_5_q2_loc_5 E_s15_5_q3_loc_9 E_s15_5_q4_loc_3 ///
	E_s15_5_q5_loc_10) ///
	(difficulties2 difficulties3 difficulties4 difficulties5 ///
	difficulties6)	

replace difficulties2 = .n if inlist(difficulties2, .,-88)
label define difficulties2_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values difficulties2 difficulties2_label

replace difficulties3 = .n if inlist(difficulties3, .,-88)
label define difficulties3_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values difficulties3 difficulties3_label

replace difficulties4 = .n if inlist(difficulties4, .,-88)
label define difficulties4_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values difficulties4 difficulties4_label

replace difficulties5 = .n if inlist(difficulties5, .,-88)
label define difficulties5_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values difficulties5 difficulties5_label

replace difficulties6 = .n if inlist(difficulties6, .,-88)
label define difficulties6_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values difficulties6 difficulties6_label

*-------------------------------------------------------------------------------
* 9. Loneliness
*-------------------------------------------------------------------------------
* Pre- and post-COVID data from rounds 1, 2, and 3 available

replace s6_q14 = s6_q14 + 1
replace s6_q3 = s6_q3 + 1

ren E_s14_q9_cesd9 loneliness
replace loneliness = s6_q14 if inlist(round, 2,3) & mi(loneliness)
replace loneliness = s6_q3 if inlist(round, 2,3) & mi(loneliness)

replace loneliness = .n if inlist(loneliness, .,-88)
drop s6_q14 s6_q3

label define loneliness_label				1 "Never + rarely" ///
											2 "Sometimes" ///
											3 "Often" ///
											4 "Always" //
label values loneliness loneliness_label

*-------------------------------------------------------------------------------
* 10. Fear
*-------------------------------------------------------------------------------
* Pre- and post-COVID data from rounds 1, 2, and 3 available

replace s6_q11 = s6_q11 + 1

ren E_s14_q6_cesd6 fear
replace fear = s6_q11 if inlist(round, 2,3) & mi(fear)

replace fear = .n if inlist(fear, .,-88)
drop s6_q11

label define fear_label				1 "Never + rarely" ///
									2 "Sometimes" ///
									3 "Often" ///
									4 "Always" //
label values fear fear_label

*-------------------------------------------------------------------------------
* 11. Hope
*-------------------------------------------------------------------------------
* Pre- and post-COVID data from rounds 1, 2, and 3 available

replace s6_q4 = s6_q4 + 1
replace s6_q10 = s6_q10 + 1
* egen hope_nonmiss = rownonmiss(s6_q4 s6_q10 E_s14_q5_cesd5)
* tab hope_nonmiss

ren s6_q4 hope1
replace hope1 = s6_q10 if inlist(round, 2,3) & mi(hope1)
replace hope1 = E_s14_q5_cesd5 if round == 1 & mi(hope1)

replace hope1 = .n if inlist(hope1, .,-88)
drop s6_q10 E_s14_q5_cesd5

label define hope1_label				1 "Never + rarely" ///
									2 "Sometimes" ///
									3 "Often" ///
									4 "Always" //
label values hope1 hope1_label

*-------------------------------------------------------------------------------
* Pre-COVID data from round 1 available

ren (E_s15_6_q1_sn1 E_s15_6_q2_sn2 E_s15_6_q3_sn3 E_s15_6_q4_sn4 E_s15_6_q5_sn5 ///
	E_s15_6_q6_sn6 E_s15_6_q7_sn7 E_s15_6_q8_sn8) ///
	(hope2 hope3 hope4 hope5 hope6 hope7 hope8 hope9) //

replace hope2 = .n if inlist(hope2, .,-88)
label define hope2_label				1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values hope2 hope2_label

replace hope3 = .n if inlist(hope3, .,-88)
label define hope3_label				1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values hope3 hope3_label

replace hope4 = .n if inlist(hope4, .,-88)
label define hope4_label				1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values hope4 hope4_label

replace hope5 = .n if inlist(hope5, .,-88)
label define hope5_label				1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values hope5 hope5_label

replace hope6 = .n if inlist(hope6, .,-88)
label define hope6_label				1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values hope6 hope6_label

replace hope7 = .n if inlist(hope7, .,-88)
label define hope7_label				1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values hope7 hope7_label

replace hope8 = .n if inlist(hope8, .,-88)
label define hope8_label				1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values hope8 hope8_label

replace hope9 = .n if inlist(hope9, .,-88)
label define hope9_label				1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values hope9 hope9_label
	
*-------------------------------------------------------------------------------
* 12. Bothering
*-------------------------------------------------------------------------------
* Pre- and post-COVID data from rounds 1, 2, and 3 available

replace s6_q6 = s6_q6 + 1

ren E_s14_q1_cesd1 bothering
replace bothering = s6_q6 if inlist(round, 2,3) & mi(bothering)

replace bothering = .n if inlist(bothering, .,-88)
drop s6_q6

label define bothering_label			1 "Never + rarely" ///
										2 "Sometimes" ///
										3 "Often" ///
										4 "Always" //
label values bothering bothering_label

*-------------------------------------------------------------------------------
* 13. Worthlessness
*-------------------------------------------------------------------------------
* Pre-COVID data from round 1 available

ren (E_s15_4_q1_se_1 E_s15_4_q2_se_2 E_s15_4_q3_se_3 E_s15_4_q4_se_4 ///
	E_s15_4_q5_se_5 E_s15_4_q6_se_6 E_s15_4_q7_se_7 E_s15_4_q8_se_8 ///
	E_s15_4_q9_se_9 E_s15_4_q10_se_10) ///
	(worthlessness1 worthlessness2 worthlessness3 worthlessness4 ///
	worthlessness5 worthlessness6 worthlessness7 worthlessness8 ///
	worthlessness9 worthlessness10)
	
replace worthlessness1 = .n if inlist(worthlessness1, .,-88)
label define worthlessness1_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values worthlessness1 worthlessness1_label

replace worthlessness2 = .n if inlist(worthlessness2, .,-88)
label define worthlessness2_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values worthlessness2 worthlessness2_label

replace worthlessness3 = .n if inlist(worthlessness3, .,-88)
label define worthlessness3_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values worthlessness3 worthlessness3_label

replace worthlessness4 = .n if inlist(worthlessness4, .,-88)
label define worthlessness4_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values worthlessness4 worthlessness4_label

replace worthlessness5 = .n if inlist(worthlessness5, .,-88)
label define worthlessness5_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values worthlessness5 worthlessness5_label

replace worthlessness6 = .n if inlist(worthlessness6, .,-88)
label define worthlessness6_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values worthlessness6 worthlessness6_label

replace worthlessness7 = .n if inlist(worthlessness7, .,-88)
label define worthlessness7_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values worthlessness7 worthlessness7_label

replace worthlessness8 = .n if inlist(worthlessness8, .,-88)
label define worthlessness8_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values worthlessness8 worthlessness8_label

replace worthlessness9 = .n if inlist(worthlessness9, .,-88)
label define worthlessness9_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values worthlessness9 worthlessness9_label

replace worthlessness10 = .n if inlist(worthlessness10, .,-88)
label define worthlessness10_label				1 "Never + rarely" ///
												2 "Sometimes" ///
												3 "Often" ///
												4 "Always" //
label values worthlessness10 worthlessness10_label


*-------------------------------------------------------------------------------
* Data Organization 
*-------------------------------------------------------------------------------

save "${out}/kenya_ge_panel.dta", replace
